<%-- $RCSFile: RadExplorer.aspx $
 Apache license v2 2011 by Christian Surieux
 $Source: ?/AddonNice/aspnet_client/FileExplorer/RadExplorer.aspx $
 $log$
 Revision 6 2010/08/09 10:51:18  christian.surieux
   Added Log comment to all .aspx .ascx .master files
 --%>
<%@ Page Language="C#" AutoEventWireup="false" Inherits="AddonNice.FileExplorer.RadExplorer" Codebehind="RadExplorer.aspx.cs" %>
<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
	<title>Seelct a File</title>
	<style type="text/css">
		body
		{
			margin: 2px;
		}
	</style>
</head>
<body>
	<form id="form1" runat="server">
	<asp:ScriptManager ID="ScriptManager1" runat="server">
	</asp:ScriptManager>
    <asp:HiddenField ID="SenderTbID" runat="server" Value="" />
	<script type="text/javascript">
		//A function that will return a reference to the parent radWindow in case the page is loaded in a RadWindow object
		function getRadWindow()
		{
			var oWindow = null;
			if (window.radWindow) oWindow = window.radWindow;
			else if (window.frameElement.radWindow) oWindow = window.frameElement.radWindow;
			return oWindow;
		}
		function OnClientGridDblClick(sender, args)
		{
			var item = args.get_item();

			//If file (and not a folder) is selected - call the OnFileSelected method on the parent page
			if (item.get_type() == Telerik.Web.UI.FileExplorerItemType.File)
			{
				args.set_cancel(true);
				//Get a reference to the opener parent page  using rad window
				var wnd = getRadWindow();
				var openerPage = wnd.BrowserWindow;
				//if you need the URL for the item, use get_url() instead of get_path()
				openerPage.OnFileSelected(wnd, item.get_path(),$get('<%= SenderTbID.ClientID %>').value);
				//Close window
				wnd.close();
			}
		}
	</script>

	<telerik:RadFileExplorer runat="server" ID="FileExplorer1" Width="500" OnClientFileOpen="OnClientGridDblClick">
		<Configuration ViewPaths="" />
	</telerik:RadFileExplorer>
	</form>
</body>
</html>
